#include "VertexFormats.fx"
#include "Lighting.fx"

float4x4 world_view_proj : WORLD_VIEW_PROJECTION;
float4x4 world : WORLD;

float3 light_pos;
float3 light_color;
float light_attenuation;

struct VSOut 
{
    float4 pos : POSITION;
    float3 color : COLOR;
};

VSOut VS_Cave(VertexPosNormal input)
{
    VSOut output;
	output.pos = mul(float4(input.pos, 1), world_view_proj);

	float3 world_pos = mul(float4(input.pos, 1), world).xyz;
	float3 normal = normalize(mul(float4(input.normal, 0), world).xyz);

	output.color = pointLight(world_pos, normal, light_pos, light_color,
		float3(0, 0, light_attenuation));

    return output;
}

float4 PS_Cave(VSOut input) : COLOR
{
    return float4(input.color, 1);
}

technique t0
{
    pass p0
    {
        VertexShader = compile vs_2_0 VS_Cave();
        PixelShader = compile ps_2_0 PS_Cave();

		ShadeMode = Flat;
    }
}
